package com.briup.corejava.day22;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 获取三种类加载器
 */
public class Test1 {
    public static void main(String[] args) {
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        ClassLoader extensionClassLoader = systemClassLoader.getParent();
        ClassLoader bootstrapClassLoader = extensionClassLoader.getParent();
        System.out.println("systemClassLoader = " + systemClassLoader);
        System.out.println("extensionClassLoader = " + extensionClassLoader);
        System.out.println("bootstrapClassLoader = " + bootstrapClassLoader);

        // 使用系统类加载器可以完成资源的加载，文件的资源相对路径
        InputStream in = systemClassLoader.getResourceAsStream("com/briup/corejava/day20/file/db.properties");
        Properties properties = new Properties();
        try {
            properties.load(in);
            System.out.println(properties.getProperty("max"));
            System.out.println(properties.getProperty("min"));

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
